<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{bundle.restatus}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form >
           <script type="text/javascript">  
                function handleSaveRestatus(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgRestatus.hide();  
                    }  
                }
                
                function handleDeleteRestatus(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgConfirmation.hide();  
                    }  
                }
                
                function componenKeyPressRestatus(e) {
                        var code = (e.keyCode ? e.keyCode : e.which);
                        if(code==13) {
                            submitrestatus.jq.click();
                            e.preventDefault();
                        }
                    }
                
            </script>  

            <p:toolbar>
                <p:toolbarGroup align="left"><!--ugpolicyBean.cekButtonAccess(5,'INS;') -->
                    <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document"  
                                     action="#{restatusBean.newData()}" rendered="#{menuBean.cekButtonAccess(5,'INS;')}"  
                                     oncomplete="dlgRestatus.show()" 
                                     process="@this" update=":#{utilityBean.findClientId('displayRestatus')}"> 
                        <pe:resetEditableValues for="displayRestatus" />
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgRestatus.show()"
                                     icon="ui-icon-disk" action="#{restatusBean.openData()}"
                                     rendered="#{menuBean.cekButtonAccess(5,'OPN;')}"  
                                     update=":#{utilityBean.findClientId('displayRestatus')}" > 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                     rendered="#{menuBean.cekButtonAccess(5,'DEL;')}"  
                                     onclick="dlgConfirmation.show()" /> 
                </p:toolbarGroup>
            </p:toolbar>
            <br />
            
            <p:dataTable var="residen" value="#{restatusBean.restatuss}" id="dtRestatuss"
                         resizableColumns="true" selection="#{restatusBean.selectedData}" selectionMode="single" rowKey="#{residen.restatusId}" 
                         rowIndexVar="noUrut">
                 <p:column style="width: 10px">
                    <f:facet name="header">No.</f:facet>
                    <h:outputText value="#{noUrut+1}" />
                 </p:column>
                <p:column style="width:200px" sortBy="#{residen.restatusName}">
                    <f:facet name="header">#{bundle.globalName}</f:facet>
                    <h:outputText value="#{residen.restatusName}" />
                </p:column>
                <p:column style="width:auto" rendered="false" >
                    <f:facet name="header">ID</f:facet>
                    <h:outputText value="#{residen.restatusId}" />
                </p:column>
            </p:dataTable>
            
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgConfirmation">
                <h:panelGrid cellspacing="0" cellpadding="0" styleClass="pComBtnD">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnYes}" update="dtRestatuss" process="@this"
                             oncomplete="handleDeleteRestatus(xhr, status, args)"  
                             actionListener="#{restatusBean.delete()}" />  
                        <p:commandButton value="#{bundle.btnCancel}" onclick="dlgConfirmation.hide()" type="button" />
                    </f:facet>
                </h:panelGrid>
            </p:confirmDialog>
        
            <p:dialog header="#{bundle.btnSearch}" widgetVar="dlgSearchRestatus" closable="true" dynamic="true">
                
                <h:panelGrid columns="2" styleClass="addELIT">
                    <h:outputLabel style="padding: 0 15px 0 0" value="#{bundle.globalName} :" />
                    <p:inputText value="#{restatusBean.filter}" size="25" />
                </h:panelGrid> 
                
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">  
                        <p:commandButton value="#{bundle.btnSearch}" icon="ui-icon-search" actionListener="#{restatusBean.search()}"
                                         update="dtRestatuss" />  
                        <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgSearchRestatus.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
            </p:dialog>
            </h:form>
            <p:dialog header="#{bundle.restatus}" widgetVar="dlgRestatus" closable="true" dynamic="true" appendToBody="true" modal="true">
                <p:ajax immediate="true" event="close" listener="#{restatusBean.handleClose}"/>
                <h:form>
                <p:focus />
                <h:panelGrid id="displayRestatus" columns="2" styleClass="addELIT" >
                    <h:outputLabel style="padding: 0 15px 0 0" value="#{bundle.globalName} :" />
                    <p:inputText rendered="#{restatusBean.insertedData!=null}" value="#{restatusBean.insertedData.restatusName}" 
                                 required="true" label="#{bundle.globalName}" size="25" onkeydown="componenKeyPressRestatus(event)"/>
                </h:panelGrid> 
                
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">  
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" action="#{restatusBean.save()}"
                                         update=":#{utilityBean.findClientId('dtRestatuss')}" id="submitrestatus" widgetVar="submitrestatus"  rendered="#{menuBean.cekButtonAccess(5,'UPD;')}"  
                                         oncomplete="handleSaveRestatus(xhr, status, args)"/>  
                        <p:commandButton immediate="true" value="#{bundle.btnClose}" oncomplete="dlgRestatus.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
                </h:form>
            </p:dialog>
        
        </ui:composition>        
    </h:body>
</html>
